home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / wd.zip / CTYPE.H < prev    next >
C/C++ Source or Header  |  1986-06-27  |  2KB  |  58 lines

  1. /*
  2.  * ctype.h
  3.  *
  4.  * defines the ctype macros as well as the character conversion macros
  5.  * (toupper, etc).
  6.  *
  7.  * Copyright (C) Microsoft Corporation, 1984, 1985, 1986
  8.  *
  9.  */
  10.  
  11. /*
  12.  * This declaration allows the user access to the ctype lookup array _ctype
  13.  * defined in ctype.o by simply including ctype.h
  14.  */
  15.  
  16. #ifndef NO_EXT_KEYS    /* extended keywords are enabled */
  17. extern unsigned char cdecl _ctype_[];
  18. extern unsigned char cdecl _ctype[];
  19. #else            /* extended keywords not enabled */
  20. extern unsigned char _ctype_[];
  21. extern unsigned char _ctype[];
  22. #endif    /* NO_EXT_KEYS */
  23.  
  24. /* set bit masks for the possible character types */
  25.  
  26. #define _UPPER        0x1       /* upper case letter */
  27. #define _LOWER        0x2       /* lower case letter */
  28. #define _DIGIT        0x4       /* digit[0-9] */
  29. #define _SPACE        0x8       /* tab, carriage return, new line,
  30.                                  * vertical tab or form feed
  31.                                  */
  32. #define _PUNCT       0x10       /* punctuation character */
  33. #define _CONTROL     0x20       /* control character */
  34. #define _BLANK       0x40       /* space char */
  35. #define _HEX         0x80       /* hexadecimal digit */
  36.  
  37. /* the macro definitions of the functions */
  38.  
  39. #define isalpha(c)     ( (_ctype+1)[c] & (_UPPER|_LOWER) )
  40. #define isupper(c)     ( (_ctype+1)[c] & _UPPER )
  41. #define islower(c)     ( (_ctype+1)[c] & _LOWER )
  42. #define isdigit(c)     ( (_ctype+1)[c] & _DIGIT )
  43. #define isxdigit(c)    ( (_ctype+1)[c] & _HEX )
  44. #define isspace(c)     ( (_ctype+1)[c] & _SPACE )
  45. #define ispunct(c)     ( (_ctype+1)[c] & _PUNCT )
  46. #define isalnum(c)     ( (_ctype+1)[c] & (_UPPER|_LOWER|_DIGIT) )
  47. #define isprint(c)     ( (_ctype+1)[c] & (_BLANK|_PUNCT|_UPPER|_LOWER|_DIGIT) )
  48. #define isgraph(c)     ( (_ctype+1)[c] & (_PUNCT|_UPPER|_LOWER|_DIGIT) )
  49. #define iscntrl(c)     ( (_ctype+1)[c] & _CONTROL )
  50. #define isascii(c)     ( (unsigned)(c) < 0x80 )
  51.  
  52. #define _tolower(c)    ( (c)-'A'+'a' )
  53. #define _toupper(c)    ( (c)-'a'+'A' )
  54.  
  55. #define toupper(c)     ( (islower(c)) ? _toupper(c) : (c) )
  56. #define tolower(c)     ( (isupper(c)) ? _tolower(c) : (c) )
  57. #define toascii(c)     ( (c) & 0x7f )
  58.